<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户列表</title>
    <script src="/js/vue.js"></script>
    <script src="/js/jquery.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="../js/lib-master/index.js"></script>
  
    <link rel="stylesheet" href="../js/lib-master/theme-chalk/index.css">
</head>
<body>
    <div id="app">
        输入搜索：
        <el-input placeholder="账户/姓名" prefix-icon="el-icon-search" v-model="userNameSelect" style="width: 300px;"></el-input>
        <el-button type="primary" icon="el-icon-search" @click="getAllUserName()" >搜索</el-button>
        <el-table :data="userData" :cell-style="rowStyle">
          <el-table-column prop="userID" label="用户编号"></el-table-column>
          <el-table-column prop="userPicture" label="头像">
            <template slot-scope="scope">
              <img :src="scope.row.userPicture" min-width="70px" height="70px">
            </template>
          </el-table-column>
          <el-table-column prop="userAccount" label="账号"></el-table-column>
          <el-table-column prop="userName" label="姓名"></el-table-column>
          <el-table-column prop="userGender" label="性别"></el-table-column>
          <el-table-column prop="userPhone" label="手机号"></el-table-column>
          <el-table-column prop="userLocation" label="所在地"></el-table-column>
          <el-table-column prop="userAddress" label="收货地址"></el-table-column>
          <el-table-column prop="userDate" label="注册时间"></el-table-column>
        </el-table>
    </div>
    <script src="/js/backcommon.js"></script>
    <script>
    
        let vm = new Vue({
          el: "#app",
          data: {
            userNameSelect:'',
            userData: [],
          },
          created: function () {
            this.getUserList()
          },
          methods: {
            rowStyle() {
              return "text-align:center";
            },
            getUserList: function () {
              //用户信息
              axios.get("/user/getAll").then(function (resp) {
                vm.userData = resp.data.data
              });
            },
            //用户查询名字或账号
            getAllUserName: function () {
              axios.get("/user/getAllName", { params: { name: vm.userNameSelect} })
                .then(function (resp) {
                  if (200 == resp.data.code) {
                    if(resp.data.data==0){
                      alert('没有此用户信息')
                    }else{
                      vm.userData=resp.data.data
                    }
                  }
                });
            },
            //重置
            userReset: function () {
               vm.getUserList()
            },
          }
        })
      </script>
</body>


</html>